/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

package com.hera.process.security.domain;

import java.io.Serializable;
import java.util.Date;
import java.util.List;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;
import javax.persistence.TableGenerator;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
import javax.persistence.Transient;

import com.hera.base.domain.BaseDomain;
import com.hera.process.config.domain.Calendar;
import com.hera.process.config.domain.Department;
import com.hera.process.config.domain.ParameterDetail;
import com.hera.process.config.domain.LoginMethod;
import com.hera.process.config.domain.Profile;
import com.hera.process.config.domain.Theme;
import com.hera.process.workflow.domain.ProcessGroup;
import com.hera.process.workflow.domain.ProcessSupervisor;

/**
 *
 * @author cmontes
 */
@Entity
@Table(name = "SYS_USER")
public class User extends BaseDomain implements Serializable {
    private static final long serialVersionUID = 1L;
    // @Max(value=?)  @Min(value=?)//if you know range of your decimal fields consider using these annotations to enforce field validation
    @Id
    @GeneratedValue(strategy = GenerationType.TABLE, generator = "User")
    @TableGenerator(name = "User", table = "sequence", pkColumnName = "seq_name", valueColumnName = "seq_id", pkColumnValue = "User", allocationSize = 1)
    @Column(name = "ID_USER")
    private Long idUser;
    @Column(name = "USER_LOGIN")
    private String userLogin;
    private String name;
    private String lastname;
    private String motherlast;
    private String password;
    @Column(name = "SUCCES_FAILED_LOGINS")
    private Long succesFailedLogins;
    @Column(name = "PASSWORD_HINT")
    private String passwordHint;
    @Column(name = "USER_LDAP_DN")
    private String userLdapDn;    
    @Column(name = "REQ_PASSWORD_CHANGE")
    private Character reqPasswordChange;
    @Column(name = "ICON_NAME")
    private String iconName;
    @Column(name = "ICON_PATH")
    private String iconPath;    
    @ManyToOne
    @JoinColumn(name="ID_STATUS")
    private ParameterDetail status;
    private String email;
    private Boolean isboss;
    @JoinColumn(name = "ID_THEME", referencedColumnName = "ID_THEME")
    @ManyToOne
    private Theme theme;
    //@OneToMany(mappedBy = "sysUser")
    @Transient
    private List<User> sysUserList;
    @JoinColumn(name = "ID_PARENT_BOSS", referencedColumnName = "ID_USER")
    @ManyToOne
    private User boss;
    @JoinColumn(name = "ID_SECURITY_GROUP", referencedColumnName = "ID_SECURITY_GROUP")
    @ManyToOne
    private SecurityGroup securityGroup;
    @JoinColumn(name = "ID_PROCESS_GROUP", referencedColumnName = "ID_PROCESS_GROUP")
    @ManyToOne
    private ProcessGroup processGroup;
    @JoinColumn(name = "ID_LOGIN_METHOD", referencedColumnName = "ID_LOGIN_METHOD")
    @ManyToOne
    private LoginMethod loginMethod;
    @JoinColumn(name = "ID_DEPARTMENT", referencedColumnName = "ID_DEPARTMENT")
    @ManyToOne
    private Department department;
    @JoinColumn(name = "ID_CALENDAR", referencedColumnName = "ID_CALENDAR")
    @ManyToOne
    private Calendar calendar;
   // @OneToMany(cascade = CascadeType.ALL, mappedBy = "sysUser")
    @Transient
    private List<ProcessSupervisor> processSupervisorList;
    //@OneToMany(mappedBy = "sysUser")
    @Transient
    private List<UserLoginHistory> userLoginHistoryList;

    @ManyToOne
    @JoinColumn(name="ID_PROFILE")
    private Profile profile;
    
    public User() {
    }

    public User(Long idUser) {
        this.idUser = idUser;
    }

    public Long getIdUser() {
        return idUser;
    }

    public void setIdUser(Long idUser) {
        this.idUser = idUser;
    }

    public String getUserLogin() {
        return userLogin;
    }

    public void setUserLogin(String userLogin) {
        this.userLogin = userLogin;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getLastname() {
        return lastname;
    }

    public void setLastname(String lastname) {
        this.lastname = lastname;
    }

    public String getMotherlast() {
        return motherlast;
    }

    public void setMotherlast(String motherlast) {
        this.motherlast = motherlast;
    }

    public String getPassword() {
        return password;
    }

    public void setPassword(String password) {
        this.password = password;
    }

    public Long getSuccesFailedLogins() {
        return succesFailedLogins;
    }

    public void setSuccesFailedLogins(Long succesFailedLogins) {
        this.succesFailedLogins = succesFailedLogins;
    }

    public String getPasswordHint() {
        return passwordHint;
    }

    public void setPasswordHint(String passwordHint) {
        this.passwordHint = passwordHint;
    }

    public String getUserLdapDn() {
        return userLdapDn;
    }

    public void setUserLdapDn(String userLdapDn) {
        this.userLdapDn = userLdapDn;
    }

    public Character getReqPasswordChange() {
        return reqPasswordChange;
    }

    public void setReqPasswordChange(Character reqPasswordChange) {
        this.reqPasswordChange = reqPasswordChange;
    }

    public String getIconName() {
        return iconName;
    }

    public void setIconName(String iconName) {
        this.iconName = iconName;
    }

    public String getIconPath() {
        return iconPath;
    }

    public void setIconPath(String iconPath) {
        this.iconPath = iconPath;
    }
    
    public ParameterDetail getStatus() {
        return status;
    }
   
    public void setStatus(ParameterDetail status) {
        this.status = status;
    }

    public String getEmail() {
        return email;
    }

    public void setEmail(String email) {
        this.email = email;
    }

    public Boolean getIsboss() {
        return isboss;
    }

    public void setIsboss(Boolean isboss) {
        this.isboss = isboss;
    }

    public Theme getTheme() {
        return theme;
    }

    public void setTheme(Theme theme) {
        this.theme = theme;
    }

    public List<User> getSysUserList() {
        return sysUserList;
    }

    public void setSysUserList(List<User> sysUserList) {
        this.sysUserList = sysUserList;
    }

    public User getBoss() {
        return boss;
    }

    public void setBoss(User sysUser) {
        this.boss = sysUser;
    }

    public SecurityGroup getSecurityGroup() {
        return securityGroup;
    }

    public void setSecurityGroup(SecurityGroup securityGroup) {
        this.securityGroup = securityGroup;
    }

    public ProcessGroup getProcessGroup() {
        return processGroup;
    }

    public void setProcessGroup(ProcessGroup processGroup) {
        this.processGroup = processGroup;
    }

    public LoginMethod getLoginMethod() {
        return loginMethod;
    }

    public void setLoginMethod(LoginMethod loginMethod) {
        this.loginMethod = loginMethod;
    }

    public Department getDepartment() {
        return department;
    }

    public void setDepartment(Department department) {
        this.department = department;
    }

    public Calendar getCalendar() {
        return calendar;
    }

    public void setCalendar(Calendar calendar) {
        this.calendar = calendar;
    }

    public List<ProcessSupervisor> getProcessSupervisorList() {
        return processSupervisorList;
    }

    public void setProcessSupervisorList(List<ProcessSupervisor> processSupervisorList) {
        this.processSupervisorList = processSupervisorList;
    }

    public List<UserLoginHistory> getUserLoginHistoryList() {
        return userLoginHistoryList;
    }

    public void setUserLoginHistoryList(List<UserLoginHistory> userLoginHistoryList) {
        this.userLoginHistoryList = userLoginHistoryList;
    }
    
    public void setFullName(String fullName) {
    	
    }
    
    public String getFullName() {
    	return lastname + " " + motherlast + ", " + name;
    }
    
    @Override
    public int hashCode() {
        int hash = 0;
        hash += (idUser != null ? idUser.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        
        if (!(object instanceof User)) {
            return false;
        }
        User other = (User) object;
        if ((this.idUser == null && other.idUser != null) || (this.idUser != null && !this.idUser.equals(other.idUser))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "com.hera.process.data.domain2.SysUser[ idUser=" + idUser + " ]";
    }

	public Profile getProfile() {
		return profile;
	}

	public void setProfile(Profile profile) {
		this.profile = profile;
	}
    
}
